import threading
import time


class MyThread(threading.Thread):
    def __init__(self, name):
        super(MyThread, self).__init__()
        self.name = name

    def run(self):

        self.test()
        print("线程被启动", self.name)

    def test(self):
        time.sleep(2)
        print("函数结束")


a = MyThread("1号线程")
a.start()
a.join()

print("主线程结束")
